<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>添加班级信息</title>
</head>
<link href="${pageContext.request.contextPath}/static/core/css/style.css">
<body>
<style>
    .modal.fade.in {
        top: 90px;
    }
</style>
<script>
    $(function () {
        selectUserDisplay()
    })

    function commint() {
        $(".add-enrol-form").submit();
    }

    /**
     * 初始化用户下来菜单
     */
    function selectUserDisplay() {
        $.ajax({
            url: _baselocation + "/getUser",
            type: 'post',
            contentType: 'application/json; charset=UTF-8',
            data: null,//一定不能给转成json字符串传过去 结果会是这样""201922101411""
            dataType: "json",
            success: function (result) {
                console.log(result)
                if (result != null) {
                    for (var i = 0; i < result.length; i++) {
                        var rol = result[i].role;
                        var rolStr = '';
                        if (rol == 1) {
                            rolStr = '管理员'
                        } else if (rol == 2) {
                            rolStr = '老师'
                        } else if (rol == 3) {
                            rolStr = '学生'
                        } else if (rol == 4) {
                            rolStr = '家长'
                        } else if (rol == 5) {
                            rolStr = '5教务人员'
                        }
                        $(".user-id").append('<option value=' + result[i].id + '>' + result[i].userCode + '   ' + rolStr + '</option>');
                    }
                }
            },
        });
    }
</script>
<!--主容器-->
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="add-enrol-form-content">
                <h1 class="text-center">添加教师</h1>
                <form class="form-horizontal add-enrol-form" enctype="multipart/form-data"
                      action="${pageContext.request.contextPath}/teacher/adddo" method="post">
                    <div class="form-group">
                        <label for="teacher-code" class="col-sm-2 control-label">教师编号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="teacherCode" id="teacher-code"
                                   placeholder="请输入教师编号">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="teacher-name" class="col-sm-2 control-label">老师名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="teacherName" id="teacher-name"
                                   placeholder="请输入老师名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="subjectId" class="col-sm-2 control-label">负责学科</label>
                        <div class="col-sm-10">
                            <select class="form-control class-enrol-id" id="subjectId" name="subjectId">
                                <option value="1"> 1</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="telephone" class="col-sm-2 control-label">电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="telephone" id="telephone" placeholder="请输入电话">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="teacher-start-time" class="col-sm-2 control-label">入职时间</label>
                        <div class="col-sm-10">
                            <input type="date" class="form-control" name="teacherStartTime" id="teacher-start-time">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="teacher-salary" class="col-sm-2 control-label">教师工资</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="teacherSalary" id="teacher-salary"
                                   placeholder="教师工资">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="teacher-address" class="col-sm-2 control-label">教师地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="teacherAddress" id="teacher-address"
                                   placeholder="请输入教师地址">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="user-id" class="col-sm-2 control-label">绑定账号</label>
                        <div class="col-sm-10">
                            <select class="form-control user-id" id="user-id" name="userId">
                                <option value="1"> 1</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="img-src" class="col-sm-2 control-label">照片</label>
                        <div class="col-sm-10">
                            <input type="file" class="form-control" id="img-src" name="file">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-5 col-sm-7">
                            <button class="btn btn-info" onclick="commint()">添加</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html>
